//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package von.seiji.cn;

import java.io.File;
import java.io.InputStream;
import java.net.URL;
import java.util.Iterator;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import org.jsoup.Jsoup;

public abstract class XmlParseUtil{

    public static Document getDoc(InputStream inputStream) {
        SAXReader sr = new SAXReader();

        try {
            return sr.read(inputStream);
        } catch (Exception var3) {
            return null;
        }
    }

    public static Document getDoc(File file) {
        SAXReader sr = new SAXReader();

        try {
            return sr.read(file);
        } catch (Exception var3) {
            return null;
        }
    }

    public static Document getDoc(URL url) {
        SAXReader sr = new SAXReader();

        try {
            return sr.read(url);
        } catch (Exception var3) {
            return null;
        }
    }

    public static Element getRoot(URL url) {
        return getDoc(url).getRootElement();
    }

    public static String getNodeText(Element root, String elementName) {
        return root.element(elementName).getTextTrim();
    }

    public static Element parse(Element node, String attr, String val) {
        Iterator iter = node.elementIterator();

        while(iter.hasNext()) {
            Element element = (Element)iter.next();
            Attribute attribute = element.attribute(attr);
            if (attribute != null) {
                String value = attribute.getValue();
                if (value != null && val.equals(value)) {
                    return element;
                }
                parse(element, val, val);
            }
        }
        return null;
    }
}
